<#include "/common/layout.html">
<@body>
<body class="gray-bg">
	<div class="wrapper">
	  <section class="content">
	    <div class="row">
	      <div class="col-xs-12">
	        <div class="box">
	         <div class="form-inline">
	          <div class="box-header">
	        	<div class="input-group input-group-sm">
	               <input type="text" name="search_value" id="search_value" class="form-control" placeholder="商品名称查询">
	               <div class="input-group-btn">
	                 <a href="javascript:;" id="search_data" class="btn btn-default" ><i class="fa fa-search"></i> 搜索</a>
	                 <a href="javascript:;" id="search_refresh" class="btn btn-default"><i class="fa fa-refresh"></i> 重置</a>
	               </div>
	            </div>
	          </div>
	         </div>
	         <div class="box-body">
	            <table id="goodComment_initTable" class="table table-bordered table-hover">
	            </table>
	         </div>
	        </div>
	      </div>
	    </div>
	  </section>
	</div>
</body>
</@body>

<script>
	$(function(){
　　	initTable();
	}); 
	var query_data = {
		goodId: $("#goodId").val()
	}
	//搜索
	$("#search_data").off().on("click", function() {
		query_data.search = $("#search_value").val();
		reloadTable();
	});
	//重置
	$("#search_refresh").off().on("click", function() {
		query_data.search = "";
		$("#search_value").val("");
		reloadTable();
	});
	//重新加载表格
	function reloadTable() {
		var oSetting = data_oTable.settings()[0];
		oSetting.ajax.data = query_data;
		data_oTable.draw();
	}
	//渲染表格
	function initTable() {
		var options = {
			id: 'goodComment_initTable',
			lengthMenu: [5, 10, 20, 50],
			pageLength: 5,
			ajax: {
				url: "/mall/comment/listPage",
				type: "POST",
				data: query_data,
			},
			columnDefs: [{
				targets: 0,
				title: "商品图片",
				orderable: !1,
				render: function(e, a, t, n) {
					return $.table.imageSquareView(t.picUrl);
				}
			},{
				targets: 1,
				title: "商品名称",
				orderable: !1,
				render: function(e, a, t, n) {
					if (t.goodName != null) {
						return t.goodName;
					} else {
						return "";
					}
				}
			},{
				targets: 2,
				title: "用户信息",
				orderable: !1,
				render: function(e, a, t, n) {
					return $.table.imageView(t.avatarUrl) + '<span>&nbsp;&nbsp;' + t.name + '</span>';
				}
			},{
				targets: 3,
				title: "评论内容",
				orderable: !1,
				render: function(e, a, t, n) {
					if (t.content != null) {
						return t.content;
					} else {
						return "";
					}
				}
			},{
				targets: 4,
				title: "评论等级",
				orderable: !1,
				render: function(e, a, t, n) {
					if (t.star == 1) {
						return '很差';
					} else if(t.star == 2) {
						return '不太满意';
					}else if(t.star == 3) {
						return '满意';
					}else if(t.star == 4) {
						return '比较满意';
					}else if(t.star == 5) {
						return '非常满意';
					}else{
						return "";
					}
				}
			},{
				targets: 5,
				title: "是否显示",
				orderable: !1,
				render: function(e, a, t, n) {
					if (t.isShow == 1) {
						return "显示";
					} else {
						return "不显示";
					}
				}
			},{
				targets: 6,
				title: "评论时间",
				orderable: !1,
				render: function(e, a, t, n) {
					if (t.createTime != null) {
						return t.createTime;
					} else {
						return "";
					}
				}
			},{
				targets: 7,
				title: "操作",
				orderable: !1,
				render: function(e, a, t, n) {
					var html = '';
						html += '<div>'
						<#if shiro.hasPermission("editComment")>
							html += '<a class="btn btn-primary btn-xs dialog" data-url="/mall/comment/check/'+ t.commentId +'" data-title="审核回复" title="审核回复"><i class="fa fa-pencil"></i>审核回复</a>'
						</#if>
						html += '</div>';
					return html;
				}
			}]
		};
		//渲染表格
		data_oTable = $.table.init(options);
	}
</script>

